<?php
/**
* 药品服务
*/
class JddjProductSvc extends JddjCommon
{
    
    /** 创建药品
     * @param $outSkuId 商家SKUID
     * @param $categoryId 到家类目编号 通过查询到家类目信息接口
     * @param $brandId 到家品牌ID 获取通过查询到家类品牌接口获取
     * @param $skuName 商品名称（格式：名称+规格）
     * @param $skuPrice 商品价格(单位：分)
     * @param $weight 重量(公斤) 单位:KG,小数点后最多保留3位
     * @param $images 商品图片 https://opendj.jd.com/img/josIcon.png, https://opendj.jd.com/img/jo.png
     * @param $fixedStatus 商家商品上下架状态 1.上架 2.下架 4.删除
     * @param $isSale 门店商品上下架(true/false)
     */
    public function addSku($outSkuId, $categoryId, $brandId, $skuName, $skuPrice, $weight, $images, $fixedStatus, $isSale)
    {
        $data = array();
        $data['outSkuId'] = $outSkuId;
        $data['categoryId'] = $categoryId;
        $data['brandId'] = $brandId;
        $data['skuName'] = $skuName;
        $data['skuPrice'] = $skuPrice;
        $data['weight'] = $weight;
        $data['images'] = $images;
        $data['fixedStatus'] = $fixedStatus;
        $data['isSale'] = $isSale;

        return $data;
    }
    /** 
     * 发送创建药品
     */
    public function sendAddSku($data = array())
    {        
        $postData = $this->getPostData($data);

        $this->DLOG("addSku : " . json_encode($postData), "run", "channel_jddj");

        $res = $this->sendData('pms/sku/addSku', $postData);

        $this->DLOG("addSku_res : " . json_encode($res, JSON_UNESCAPED_UNICODE), "run", "channel_jddj");

        return $res['data'];
    }

    /** 更新药品
     * @param $outSkuId 商家SKUID
     * @param $categoryId 到家类目编号 通过查询到家类目信息接口
     * @param $brandId 到家品牌ID 获取通过查询到家类品牌接口获取
     * @param $skuName 商品名称（格式：名称+规格）
     * @param $skuPrice 商品价格(单位：分)
     * @param $weight 重量(公斤) 单位:KG,小数点后最多保留3位
     * @param $images 商品图片 https://opendj.jd.com/img/josIcon.png, https://opendj.jd.com/img/jo.png
     * @param $fixedStatus 商家商品上下架状态 1.上架 2.下架 4.删除
     * @param $isSale 门店商品上下架(true/false)
     */
    public function updateSku($outSkuId, $categoryId, $brandId, $skuName, $skuPrice, $weight, $images, $fixedStatus, $isSale)
    {
        $data = array();
        $data['outSkuId'] = $outSkuId;
        $data['categoryId'] = $categoryId;
        $data['brandId'] = $brandId;
        $data['skuName'] = $skuName;
        $data['skuPrice'] = $skuPrice;
        $data['weight'] = $weight;
        $data['images'] = $images;
        $data['fixedStatus'] = $fixedStatus;
        $data['isSale'] = $isSale;

        return $data;
    }
    /** 
     * 发送更新药品
     */
    public function sendUpdateSku($data = array())
    {        
        $postData = $this->getPostData($data);

        $this->DLOG("updateSku : " . json_encode($postData), "run", "channel_jddj");

        $res = $this->sendData('pms/sku/updateSku', $postData);

        $this->DLOG("updateSku_res : " . json_encode($res, JSON_UNESCAPED_UNICODE), "run", "channel_jddj");

        return $res;
    }

    /** 查询商家已上传商品信息列表接口
     * @param $skuName 商品名称
     * @param $upcCode 商品UPC编码
     * @param $skuId 到家商品编号
     * @param $pageNo 当前页
     * @param $pageSize 分页大小
     * @param $isFilterDel 是否查询出已删除的上传商品(0代表不查已删除商品,不填则查出全部商品)
     */
    public function querySkuInfos($skuName, $upcCode, $skuId, $pageNo, $pageSize, $isFilterDel)
    {
        $data = array();
        $data['skuName'] = $skuName;
        $data['upcCode'] = $upcCode;
        $data['skuId'] = $skuId;
        $data['pageNo'] = $pageNo;
        $data['pageSize'] = $pageSize;
        $data['isFilterDel'] = $isFilterDel;
        
        return $data;
    }
    /** 
     * 发送查询商家已上传商品信息列表接口
     */
    public function sendQuerySkuInfos($data = array())
    {        
        $postData = $this->getPostData($data);

        $this->DLOG("querySkuInfos : " . json_encode($postData), "run", "channel_jddj");

        $res = $this->sendData('pms/querySkuInfos', $postData);

        $this->DLOG("querySkuInfos_res : " . json_encode($res, JSON_UNESCAPED_UNICODE), "run", "channel_jddj");

        return $res;
    }

    /** 获取京东到家类目信息接口
     * @param $id 父分类Id
     * @param $fields 定义需要返回的字段列表
     */
    public function queryChildCategoriesForOP($id, $fields)
    {
        $data = array();
        $data['id'] = $id;
        $data['fields'] = $fields;

        return $data;
    }
    /** 
     * 发送获取京东到家类目信息接口
     */
    public function sendQueryChildCategoriesForOP($data = array())
    {        
        $postData = $this->getPostData($data);

        $this->DLOG("queryChildCategoriesForOP : " . json_encode($postData), "run", "channel_jddj");

        $res = $this->sendData('api/queryChildCategoriesForOP', $postData);

        $this->DLOG("queryChildCategoriesForOP_res : " . json_encode($res, JSON_UNESCAPED_UNICODE), "run", "channel_jddj");

        return $res;
    }

    /** 根据商家商品编号和商家门店编号批量修改现货库存接口
     * @param $stationNo 到家门店编号
     * @param $userPin 操作人pin
     * @param $skuStockList 商品信息，最多50条
     */
    public function batchUpdateCurrentQtys($stationNo, $userPin, $skuStockList)
    {
        $data = array();
        $data['stationNo'] = strval($stationNo);
        $data['userPin'] = $userPin;
        $data['skuStockList'] = $skuStockList;

        return $data;
    }
    /** 
     * 发送根据商家商品编号和商家门店编号批量修改现货库存接口
     */
    public function sendBatchUpdateCurrentQtys($data = array())
    {        
        $postData = $this->getPostData($data);

        $this->DLOG("batchUpdateCurrentQtys : " . json_encode($postData), "run", "channel_jddj");

        $res = $this->sendData('stock/batchUpdateCurrentQtys', $postData);

        $this->DLOG("batchUpdateCurrentQtys_res : " . json_encode($res, JSON_UNESCAPED_UNICODE), "run", "channel_jddj");

        return $res;
    }

    /** 根据商家商品编号和商家门店编号批量修改门店价格接口
     * @param $stationNo 到家门店编号
     * @param $skuPriceInfoList 商品信息，最多50条
     */
    public function batchUpdateStationPrice($stationNo, $skuPriceInfoList)
    {
        $data = array();
        $data['stationNo'] = strval($stationNo);
        $data['skuPriceInfoList'] = $skuPriceInfoList;

        return $data;
    }
    /** 
     * 发送根据商家商品编号和商家门店编号批量修改门店价格接口
     */
    public function sendBatchUpdateStationPrice($data = array())
    {        
        $postData = $this->getPostData($data);

        $this->DLOG("batchUpdateStationPrice : " . json_encode($postData), "run", "channel_jddj");

        $res = $this->sendData('venderprice/updateStationPrice', $postData);

        $this->DLOG("batchUpdateStationPrice_res : " . json_encode($res, JSON_UNESCAPED_UNICODE), "run", "channel_jddj");

        return $res;
    }

    /** 根据到家商品编码和到家门店编码批量更新锁定库存接口
     * @param $listBaseStockCenterRequest 参数实体列表，单次最多50个商品
     */
    public function updateOpenLockQtys($listBaseStockCenterRequest)
    {
        $data = array();
        $data['listBaseStockCenterRequest'] = $listBaseStockCenterRequest;

        return $data;
    }
    /** 
     * 发送根据到家商品编码和到家门店编码批量更新锁定库存接口
     */
    public function sendUpdateOpenLockQtys($data = array())
    {        
        $postData = $this->getPostData($data);

        $this->DLOG("updateOpenLockQtys : " . json_encode($postData), "run", "channel_jddj");

        $res = $this->sendData('stock/updateOpenLockQtys', $postData);

        $this->DLOG("updateOpenLockQtys_res : " . json_encode($res, JSON_UNESCAPED_UNICODE), "run", "channel_jddj");

        return $res;
    }

    /** 批量查询商品可用与锁定库存、门店上下架状态信息接口
     * @param $listBaseStockCenterRequest 参数实体列表，单次最多50个商品
     */
    public function queryOpenUseable($listBaseStockCenterRequest)
    {
        $data = array();
        $data['listBaseStockCenterRequest'] = $listBaseStockCenterRequest;

        return $data;
    }
    /** 
     * 发送批量查询商品可用与锁定库存、门店上下架状态信息接口
     */
    public function sendQueryOpenUseable($data = array())
    {        
        $postData = $this->getPostData($data);

        $this->DLOG("queryOpenUseable : " . json_encode($postData), "run", "channel_jddj");

        $res = $this->sendData('stock/queryOpenUseable', $postData);

        $this->DLOG("queryOpenUseable_res : " . json_encode($res, JSON_UNESCAPED_UNICODE), "run", "channel_jddj");

        return $res;
    }

    
}